<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增礼品卡')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-card-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">起始码序号：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input id="startCode" name="startCode" class="form-control" type="number" required>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">终止码序号：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input id="endCode" name="endCode" class="form-control" type="number" required>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "core/card"
        $().ready(function() {
            validateRule();
        });
        function validateRule() {
            var icon = "<i class='fa fa-times-circle'></i> ";
            $('#form-card-add').validate({
                focusCleanup: true,
                rules : {
                    startCode : {
                        remote : {
                            url: prefix+"/getRemoveCode",
                            type: "Post",
                            data: {
                                removeCode: function () { return $("#startCode").val()},
                            }
                        }
                    },
                    endCode : {
                        remote : {
                            url: prefix+"/getRemoveCode",
                            type: "Post",
                            data: {
                                removeCode: function () { return $("#endCode").val()},
                            }
                        }
                    }
                },
                messages: {
                    startCode : {
                        remote :icon+ "该序列号的礼品卡不存在或没有相应码"
                    },
                    endCode : {
                        remote :icon+ "该序列号的礼品卡不存在或没有相应码"
                    }
                }
            })
        }

     /*   $("#form-card-add").validate({

        });*/

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/removeCodes", $('#form-card-add').serialize());
            }
        }
    </script>
</body>
</html>